package code.example.base.data.struct.sort;

import code.example.tool.LogFactory;

import java.util.Arrays;

public class SortTester {

    private void print(int [] data){
        String str = Arrays.toString(data);
        LogFactory.getLog().info(str);
    }
    private int [] copy(int [] data){
        int [] dest = new int [data.length];
        System.arraycopy(data,0,dest,0,data.length);
        return dest;
    }
    private void testBubbleSort(int [] array){
        int [] data = copy(array);
        print(data);
        BubbleSort  bubbleSort = new BubbleSort();
        bubbleSort.sort(data);
        print(data);
    }
    public void testSelectionSort(int [] array){
        int [] data = copy(array);
        print(data);
        SelectionSort selectionSort = new SelectionSort();
        selectionSort.sort(data);
        print(data);

    }
    public void testInsertionSort(int  [] array){
        int [] data = copy(array);
        print(data);
        InsertionSort insertionSort = new InsertionSort();
        insertionSort.sort(data);
        print(data);
    }

    public static void main(String [] args){
        int [] data = new int []{ 9,8,7,4,5,6,3,1,2};
        SortTester sortTester = new SortTester();
        //sortTester.testBubbleSort(data);
        //sortTester.testSelectionSort(data);
        sortTester.testInsertionSort(data);
    }
}
